<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>喜来乐相亲网站</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
    <style>
    .dv01{
      margin-top:10%;
    }
    .dv02{
      margin-top:2%;
    }
    .dv03{
      margin-top:3%;
    }
  </style>
</head>
<body style="background-color: beige;">

<div class="container">
    <div class="row dv01">
        <div class="col-sm-offset-4 col-sm-4">
            <h1>进行密码找回</h1>
        </div>
    </div>
    <div class="row dv02 clearfix">
        <div class="col-md-6 column">
            <img alt="140x140" src="img/z1.jpg" style="width:100%" />
        </div>
        <div class="col-md-6 column">
            <form class="form-horizontal" style="margin-top:10%" role="form" id="fm1">
                <div class="form-group">
                    <label for="ip1" class="col-sm-3 control-label">账号：</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="username" id="ip1" placeholder="请输入账号" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="ip2" class="col-sm-3 control-label">新密码：</label>
                    <div class="col-sm-9">
                        <input type="password" class="form-control" name="password" id="ip2" placeholder="请输入新密码" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="ip3" class="col-sm-3 control-label">确认密码：</label>
                    <div class="col-sm-9">
                        <input type="password" class="form-control" id="ip3" placeholder="请再次输入密码" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-9">
                        <button type="button" id="btn1" style="width:100%" class="btn btn-default">密码找回</button>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-5">
                        没有账号，<a href="register.html">点击注册账号</a>
                    </div>
                    <div class="col-sm-4" style="text-align:right">
                        已有账号，<a href="login.html">点击找登陆账号</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="row clearfix dv03">
        <div class="col-md-12 column">
            <div>©喜来乐相亲网站 豫ICP证110507号 豫ICP备10046444号 豫公网安备11010802020134号 豫网文[2022]0059-0009号</div>
        </div>
    </div>
</div>
<script>
  $(function(){
        //检查输入框的变化，校验2次密码是否一致
        $("#ip3").change(function(){
            var p1=$("#ip2").val();
            var p2=$("#ip3").val();
            if(p1==p2){
                //密码输入一致
                alert("两次密码一样");
            }else{
                //密码不一致
                alert("两次密码不一致");
            }
        })
      //绑定按钮的点击事件
      $("#btn1").click(function(){
        //ajax请求后端接口
        $.post("/api/user/findpass",$("#fm1").serialize(),function(res){
            if(res==200){
              //找回成功
              location.href="login.html";
            }else if(res==300){
              alert("亲，账号不存在，请注册");
              location.href="register.html";
            }else{
                alert("亲，网络异常，请重试");
            }
        })
      })
  });
</script>
</body>
</html>